<div class="row-content am-cf">
    <div class="row">
        <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
            <div class="widget am-cf">
                <div class="widget-head am-cf">
                    <div class="widget-title am-cf">二维码规则列表</div>
                </div>
                <div class="widget-body am-fr">
                    {if $list['errcode']==0}
                    <div class="tips am-margin-bottom-sm am-u-sm-12">
                        <div class="pre-warning">
                            <p>规则数量：{$list['total_count']}，本月还可发布{$list['qrcodejump_pub_quota']}次</p>
                        </div>
                    </div>
                    {/if}
                    <div class="am-u-sm-12 am-u-md-6 am-u-lg-6">
                        <div class="am-form-group">
                            <div class="am-btn-toolbar">
                                <div class="am-btn-group am-btn-group-sm">
                                    <a href="javascript:void(0);" class="hema-add am-btn am-btn-primary am-radius">
                                        <span class="am-icon-plus"></span> 添加
                                    </a>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="am-u-sm-12">
                        <table width="100%" class="am-table am-table-hover tpl-table-black">
                            <thead>
                            <tr>
                                <th>二维码规则</th>
                                <th>跳转页面</th>
                                <th>使用范围</th>
								<th>发布状态</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            {if $list['errcode']==0 AND sizeof($list['rule_list'])>0}
                                {foreach $list['rule_list'] as $item}
                                <tr>
                                    <td class="am-text-middle">{$item['prefix']}</td>
                                    <td class="am-text-middle">{$item['path']}</td>
                                    <td class="am-text-middle">
                                        {$item['open_version']==1?'开发版':''}
                                        {$item['open_version']==2?'体验版':''}
                                        {$item['open_version']==3?'正式版':''}
                                    </td>
									<td class="am-text-middle">
                                        <span class="am-badge 
                                            {$item['state'] == 1 ? ' am-badge-warning j-status' : ''}
                                            {$item['state'] == 2 ? ' am-badge-success' : ''}" 
                                            data-id="{$item['prefix']}">
                                            {$item['state']==1?'未发布':''}
                                            {$item['state']==2?'已发布':''}
                                        </span>
                                    </td>
                                    <td class="am-text-middle">
                                        <div class="tpl-table-black-operation">
                                            <a href="javascript:;" class="hema-edit" 
                                                data-prefix="{$item['prefix']}"
                                                data-path="{$item['path']}"
                                                data-open_version="{$item['open_version']}">
                                                <i class="am-icon-pencil"></i> 编辑
                                            </a>
                                            <a href="javascript:;" class="hema-del tpl-table-black-operation-del"
                                               data-id="{$item['prefix']}">
                                                <i class="am-icon-trash"></i> 删除
                                            </a>
                                        </div>
                                    </td>
                                </tr>
                                {/foreach}
                            {else /}
                                <tr>
                                    <td colspan="5" class="am-text-center">
                                        {$list['errcode'] == 0 ? '暂无记录' : 'code：'.$list['errcode'].'，msg：'.$list['errmsg']}
                                    </td>
                                </tr>
                            {/if}
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="wxapp/qrcode/add" /}
{include file="wxapp/qrcode/edit" /}
<script>
    $(function () {
         //添加
        $('.hema-add').on('click', function () {
            $.showAction({
                title: '添加二维码规则', 
                area: '750px', 
                content: template('tpl-add', {}), 
                uCheck: true, 
                success: function ($content) {
                    $('#my-form').formPost({
                        url: "{:url('wxapp.qrcode/add')}"
                    });
                }, 
                btn2: function ($content) {
                    return true;
                }
            });
        });
        //编辑
        $('.hema-edit').on('click', function () {
            var data = $(this).data();
            var prefix = data.prefix;
            data.prefix = prefix.slice(BASE_URL.length);
            $.showAction({
                title: '编辑二维码规则', 
                area: '750px', 
                content: template('tpl-edit', data), 
                uCheck: true, 
                success: function ($content) {
                    $('#my-form').formPost({
                        url: "{:url('wxapp.qrcode/edit')}"
                    });
                }, 
                btn2: function ($content) {
                    return true;
                }
            });
        });
        // 切换上架状态
        $('.j-status').click(function () {
            var data = $(this).data();
			var msg = '确定要进行发布操作？';
            var url = "{:url('wxapp.qrcode/status')}";
			$('.j-status').del('id', url,msg);
        });
        // 删除元素
        var url = "{:url('wxapp.qrcode/delete')}";
        $('.hema-del').del('id', url);

    });
</script>

